package com.example.demo01.Impl.webImpl;

import com.example.demo01.Dao.webDao.AdminUserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class AdminUserDaoImpl implements AdminUserDao {
    //自动装配成员属性
    @Autowired
    private JdbcTemplate jdbcTemplate;

    //覆写方法
    @Override
    public int validAccounrByAccount(String account, String password) {
//        #查询用户是否存在
//         OR (adminuser.phoneNum='13137188108' AND adminuser.password='123456')
        String sqlQuery="SELECT COUNT(*) as 'nums' FROM adminuser WHERE adminuser.username=? AND adminuser.password=?";
        return jdbcTemplate.queryForObject(sqlQuery,new Object[]{account,password},Integer.class);
    }

    @Override
    public int validAccounrByPhoneNum(String phoneNum, String password) {
        String sqlQuery="SELECT COUNT(*) as 'nums' FROM adminuser WHERE adminuser.phoneNum=? AND adminuser.password=?";
        return jdbcTemplate.queryForObject(sqlQuery,new Object[]{phoneNum,password},Integer.class);
    }
}
